<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Diskimrum GIS : Aktifasi Akun</title>
	<link href="../assets/css/verifikasi.css" type="text/css" rel="stylesheet" />
</head>
<body>
	<!-- start header div -->	
	<div id="header">
		<h2>Diskimrum GIS : Aktifasi Akun</h2>
	</div>
	<!-- end header div -->	
	
	<!-- start wrap div -->	
	<div id="wrap">
	    <!-- start PHP code -->
	    <?php
	    
	    	require ('../class/admin.php');
			
			if(isset($_GET['email']) && !empty($_GET['email']) AND isset($_GET['code']) && !empty($_GET['code'])){
				// Verify data
				$email = mysql_escape_string($_GET['email']); // Set email variable
				$hash = mysql_escape_string($_GET['code']); // Set hash variable
				
				$search = mysql_query("SELECT email, kode_aktifasi, aktif FROM user WHERE email='".$email."' AND kode_aktifasi='".$hash."' AND aktif='0'") or die(mysql_error()); 
				$match  = mysql_num_rows($search);
				
				if($match > 0){
					// We have a match, activate the account
					mysql_query("UPDATE user SET aktif='1' WHERE email='".$email."' AND kode_aktifasi='".$hash."' AND aktif='0'") or die(mysql_error());
					echo '<div class="statusmsg">Akun anda sudah aktif, klik <a href="index.php">disini</a> untuk login</div>';
				}else{
					// No match -> invalid url or account has already been activated.
					echo '<div class="statusmsg">Tautan tidak dikenali atau akun anda sudah aktif.</div>';
				}
				
			}else{
				// Invalid approach
				echo '<div class="statusmsg">Tautan tidak dikenali, silahkan gunakan tautan yang dikirim ke email anda.</div>';
			}
	    	
	    ?>
	    <!-- stop PHP Code -->

		
	</div>
	<!-- end wrap div -->	
</body>
</html>
